package com.bykj.property.mapper.provider;

import com.bykj.property.controller.vo.request.ChargeStandardPageRequest;
import com.bykj.property.controller.vo.request.ChargeTypePageRequest;
import org.apache.commons.lang3.StringUtils;
import org.apache.ibatis.jdbc.SQL;

/**
 * @author yiming
 * @title: ChargeTypeSql
 * @projectName property
 * @description: TODO
 * @date 2019/6/2818:05
 */
public class ChargeTypeSql {
    public String getSql(ChargeTypePageRequest pageRequest){
        return new SQL() {
            {
                SELECT("*");
                FROM("charge_type");
                if(!StringUtils.isEmpty(pageRequest.getChargeName())) {
                    pageRequest.setChargeName("%"+pageRequest.getChargeName()+"%");
                    WHERE("charge_name like #{chargeName}");
                }
                if(!StringUtils.isEmpty(pageRequest.getChargeNumber())) {
                    pageRequest.setChargeNumber("%"+pageRequest.getChargeNumber()+"%");
                    WHERE("charge_number like #{chargeNumber}");
                }

            }
        }.toString();

    }
}
